package com.gc.ip.util;

import com.gc.ip.IPAddress;
import com.gc.ip.IPType;

public class IPAddressParseResult
{
	public static enum ErrorType
	{
		OK, EMPTY_INPUT, INVALID_ADDRESS, INVALID_PREFIX
	};

	// Result IPAddress
	private IPAddress ipAddress;

	// Error Values
	private ErrorType errorType;

	public IPAddressParseResult()
	{
		reset();
	}

	public void reset()
	{
		this.ipAddress = null;
		this.errorType = ErrorType.EMPTY_INPUT;
	}

	public IPAddress getIPAddress()
	{
		return this.ipAddress;
	}
	public void setIPAddress(IPAddress ipAddress)
	{
		this.ipAddress = ipAddress;
	}

	public IPType getIPType()
	{
		if(errorType == null || errorType != ErrorType.OK || this.ipAddress == null)
		{
			return IPType.NONE;
		}
		return ipAddress.getIPType();
	}
	/**
	 * @return the errorType
	 */
	public ErrorType getErrorType()
	{
		return errorType;
	}

	/**
	 * @param errorType
	 *            the errorType to set
	 */
	public void setErrorType(ErrorType errorType)
	{
		this.errorType = errorType;
	}
}
